Skip to content

Conversation

@evgeny-bushuev-incountry
Copy link
Contributor

fix #1032

- /etc/confd/conf.d/haproxy.toml
- /etc/confd/templates/haproxy.tmpl
delegate_to: "{{ groups.balancers[0] }}"
when: "'balancers' in group_names"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, there will be an error because there will be a new haproxy node in the group that we are adding.
It is necessary to get files from the first node of the group.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the first node in the group will be a new node?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this?

when:
- 'balancers' in group_names
- not new_node | bool

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the first node in the group will be a new node?

it is assumed that the user has read the documentation

all necessary configuration files will be copied from the first server listed in the "balancers" group in the inventory file.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this?

I think it will work.

flat: true
notify: "restart haproxy"
delegate_to: "{{ groups.balancers[0] }}"
when: "'balancers' in group_names"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary to fetch files from the first node of the group.

validate_checksum: true
flat: true
delegate_to: "{{ groups.balancers[0] }}"
when: "'balancers' in group_names"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also - first node in the group.

validate_checksum: true
flat: true
delegate_to: "{{ groups.balancers[0] }}"
when: "'balancers' in group_names"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
when: "'balancers' in group_names"
when: "'balancers' in group_names and inventory_hostname == groups['balancers'][0]"

run_once: true
ansible.builtin.command: "pgbackrest --stanza={{ pgbackrest_stanza }} --no-online stanza-create"
register: stanza_create_result
when: "'pgbackrest' in group_names"
Copy link
Owner

@vitabaks vitabaks May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition will not work because only the postgres_cluster group is declared in PLAY.

- name: vitabaks.autobase.deploy_pgcluster | PostgreSQL Cluster Deployment
  hosts: postgres_cluster

In this case, you need a separate PLAY for the pgbackest group.

when: not pgbouncer_auth_user|bool
when:
- not pgbouncer_auth_user|bool
- when: "'master' in group_names"
Copy link
Owner

@vitabaks vitabaks May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug :)

Suggested change
- when: "'master' in group_names"
- "'master' in group_names"

until: update_pgbackrest_package is success
delay: 5
retries: 3
when: "'pgbackrest' in group_names"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition will not work because only the "primary:secondary" groups is declared in PLAY.

- name: "(1/4) PRE-UPDATE: Perform pre-update tasks"
  hosts: "primary:secondary"

In this case, you need a separate PLAY for the pgbackest group.

when: pg_path_count.stdout | int > 0 and pgbackrest_stanza_upgrade | bool
when:
- pg_path_count.stdout | int > 0 and pgbackrest_stanza_upgrade | bool
- "'pgbackrest' in group_names"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition will not work because only the "primary:secondary" groups is declared in PLAY.

- name: "(6/6) POST-UPGRADE: Analyze a PostgreSQL database (update optimizer statistics) and Post-Upgrade tasks"
  hosts: "primary:secondary"
  ...

    - name: Running Post-Upgrade tasks
      ansible.builtin.include_role:
        name: vitabaks.autobase.upgrade
        tasks_from: post_upgrade

For this reason, delegate_to was used.

@vitabaks vitabaks changed the title fix delegate_to {{ group_name[0] }} bug Drop delegate_to for SSH jump host compatibility May 30, 2025
@vitabaks vitabaks marked this pull request as draft June 30, 2025 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

delegate_to "{{ group_name[0] }}" doesn't work when connect to host via ssh jump-host

2 participants